package com.example.core.po;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.example.core.utils.UUIDUtils;
import lombok.Data;

import java.util.Date;

@Data
@TableName(value = "sys_license_param")
public class SysLicenseParam extends Model<SysLicenseParam> {

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;

    //授权对象
    @TableField(value = "subject")
    private String subject;

    //该密码生成密钥对的密码，需要妥善保管，不能让使用者知道
    @TableField(value = "key_pwd")
    private String keyPwd = UUIDUtils.uuid();

    //密钥别名
    @TableField(value = "private_alias")
    private String privateAlias = UUIDUtils.uuid();

    //设置对证书内容加密的对称密码
    @TableField(value = "store_pwd")
    private String storePwd = UUIDUtils.uuid();

    //过期时间
    @TableField(value = "expire_time")
    private Date expireTime;

    //许可地址
    @TableField(value = "lic_path")
    private String licPath = IdUtil.getSnowflakeNextIdStr() + ".lic";

    //许可签发时间
    @TableField(value = "issued_time")
    private Date issuedTime = new Date();

    //不可早于时间
    @TableField(value = "not_before")
    private Date notBefore;

    //不可晚于时间
    @TableField(value = "not_after")
    private Date notAfter;

    //证书名称
    @TableField(value = "cert_file")
    private String certfile = UUIDUtils.uuid();

    //私钥的文件名称
    @TableField(value = "private_key")
    private String privateKey = UUIDUtils.uuid();

    //公钥的文件名称
    @TableField(value = "public_key")
    private String publicKey = UUIDUtils.uuid();

    //授权类型
    @TableField(value = "consumer_type")
    private String consumerType = "user";

    //授权数
    @TableField(value = "consumer_amount")
    private int consumerAmount = 1;

    //描述信息
    @TableField(value = "info")
    private String info;

    //ip信息
    @TableField(value = "ip")
    private String ip;

    //mac地址信息
    @TableField(value = "mac")
    private String mac;
}

